home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / patch / ppak25_1.lha / PhonePak_2.5 / rexxAutoDelete.ppak < prev    next >
Text File  |  1994-05-18  |  5KB  |  133 lines

  1. /****************************************************************************/
  2. /*  This is a PhonePak ARexx script that executes its argument as an        */
  3. /*  Operator string, and if the execution is successful, automatically      */
  4. /*  deletes any fax files found in the Operator string.  Typically, this    */
  5. /*  script would be specified under the Group= Tool Type in PPakFax's icon. */
  6. /****************************************************************************/
  7.  
  8. /***************/
  9. /*  Constants  */
  10. /***************/
  11.  
  12. interval = 10                           /* Minutes before next attempt */
  13. maxlines = 5                            /* Maximum number of phone lines */
  14.  
  15. /******************/
  16. /*  MAIN ROUTINE  */
  17. /****************************************************************************/
  18.  
  19. options failat 101
  20. options results
  21.  
  22. addlib("libs:rexxsupport.library",0,-30,0)
  23.  
  24. arg PhoneNumber                             /* Get args handed in by LineMan */
  25. Upper PhoneNumber
  26.  
  27. Mailbox = GetDirName(pragma('d'))           /* Get mailbox name (current dir) */
  28. Upper Mailbox                               /* Make sure its upper case */
  29.  
  30. /***********************************/
  31. /*  Try to find an available line  */
  32. /***********************************/
  33.  
  34. x = 1
  35. do forever
  36.     PortName = 'LINEMAN.' || x              /* Assemble the port name */
  37.     if show('P', PortName) then do          /* See if the port is present */
  38.         address value PortName              /* Modify host address */
  39.         call ExOp()                         /* Only returns if call should */
  40.         end                                 /* be tried on another line. */
  41.     if x = maxlines then
  42.         exit interval "'Line not avail'"    /* Outer quotes get stripped */
  43.     else
  44.         x = x + 1                           /* Increment line # and continue */
  45.     end
  46.  
  47. /****************************************************************************/
  48.  
  49. /*********************************/
  50. /*  SUBROUTINE                   */
  51. /*  Execute Operator string      */
  52. /*********************************/
  53.  
  54. ExOp:
  55.     CHANGEDIR pragma('d')       /* Set LineMan's current dir to mailbox dir */
  56.     OPERATOR PhoneNumber        /* Dial the phone number */
  57.     DialResult = rc
  58.  
  59.     if DialResult ~= 0 then                     /* Hang up on error */
  60.         Operator '<H>' 
  61.  
  62.     select
  63.         when DialResult = -3 then               /* Make sure phone # is 'raw' */
  64.             exit "-1 'Procedure error'"      
  65.         when DialResult = -2 then               /* Probably a missing message */
  66.             exit "-1 'I/O error'"      
  67.         when DialResult = -1 then       
  68.             exit "-1 'Syntax error'"      
  69.  
  70.         when DialResult = 0 then     
  71.             nop
  72.         when DialResult = 1 then     
  73.             exit interval "'Resource error'"      
  74.         when DialResult = 2 then     
  75.             exit interval "'Local pickup'"      
  76.         when DialResult = 4 then     
  77.             return      
  78.         when DialResult = 5 then     
  79.             exit interval "'No dialtone'"      
  80.         when DialResult = 6 then
  81.             exit interval "'No answer'"      
  82.         when DialResult = 7 then
  83.             exit "-1 'Fax error'"      
  84.         when DialResult = 8 then
  85.             exit interval "'Busy signal'"      
  86.  
  87.         when DialResult = 98 | DialResult = 99 then     
  88.             return      
  89.         otherwise
  90.             exit "-1 'Fatal error'"      
  91.         end
  92.  
  93.  
  94. /**********************/
  95. /*  Delete fax files  */
  96. /**********************/
  97.  
  98.     Index = 1
  99.  
  100.     do forever    
  101.         Index = pos('<X', PhoneNumber, Index)
  102.         if Index > 0 then do                        /* Find Xmit command */
  103.             Index = pos(' ', PhoneNumber, Index)    /* Find arg */
  104.             Work = substr(PhoneNumber, Index + 1)   /* Copy arg */
  105.             End = pos('>', Work)                    /* Find end of arg */
  106.             Work = delstr(Work, End)                /* Strip chars after arg */
  107.  
  108.             Info = statef(Work)                     /* Get info about file */
  109.             if word(Info, 8) = 'New' then           /* If file is new */
  110.                 ADJNEWCOUNT Mailbox '-1'            /* Decrement newcount */
  111.  
  112.             delete(Work)                            /* Delete file */
  113.             end
  114.         else
  115.             break
  116.         end
  117.  
  118.     exit                                            /* Success! */
  119.  
  120. /***********************************/
  121. /*  SUBROUTINE                     */
  122. /*  Get name of current directory  */
  123. /***********************************/
  124.  
  125. GetDirName:
  126.     path = arg(1)
  127.     n = lastpos("/",path)
  128.     
  129.     if n=0 then
  130.         n = lastpos(":",path)
  131.         
  132.     return substr(path, n+1)
  133.